#!/usr/bin/python
# -*- encoding: utf-8 -*-

"""
@File:      tc_ag_util-linux-user_chfn_002.py
@Time:      2022/06/20 11:12:50
@Author:    zhangtaibo
@Version:   1.0
@Contact:   zhangtaibo.ztb@alibaba-inc.com
@License:   Mulan PSL v2
@Modify:    sunqingwei 
"""

from common.basetest import LocalTest

class Test(LocalTest):
    """
    See tc_ag_util-linux-user_chfn_fun_002.yaml for details

    :avocado: tags=fix,P1,noarch,local,ag
    """
    PARAM_DIC = {"pkg_name": "util-linux-user"}
    def setUp(self):
        super().setUp(self.PARAM_DIC)
        self.cmd("useradd tldr-user",ignore_status=True)
    
    def test(self):
        add_list = ["beijing","西安"]
        for add in add_list:
            ret_c, ret_o = self.cmd(f"chfn -o {add} tldr-user")
            info_c, info_o = self.cmd("cat /etc/passwd |grep tldr-user")
            info_list = info_o.split(':')[4].split(',')
            self.assertEqual(info_list[1],add) 

    def tearDown(self):
        super().tearDown(self.PARAM_DIC)
        self.cmd("userdel -r tldr-user")
